﻿using System.Collections;
using System.Collections.Generic;
using Uniblocks;
using UnityEngine;

public class WorldManager : MonoBehaviour
{
    private Index lastIndex;
    // Use this for initialization
    void Start()
    {
        Utl.instance.WaitForFrame(3, () =>
        {
            ChunkManager.SpawnChunks(Vector3.up*11);
        });
    }

    // Update is called once per frame
    void Update()
    {
        if (GameManager.instance.playerTrans != null)
        {
            Index curIndex = Engine.PositionToChunkIndex(GameManager.instance.playerTrans.position);
            if (!curIndex.IsEqual(lastIndex))
            {
                Debug.Log("create chunk");
                ChunkManager.SpawnChunks(GameManager.instance.playerTrans.position);
                lastIndex = curIndex;
            }
        }
    }
}
